#!/usr/bin/env ruby

class Movie
    attr_accessor :price, :type
    
    def initialize(&block)
        instance_eval(&block)
    end

    def justprint
        puts "Type:#{self.type} and Price:#{self.price}"
    end
    
    def info
        yield(self.type, self.price)
    end
    
    def infoo(&block)
        instance_eval(&block)
    end
end

Movie.class_eval do
    def foo
        puts 'this is the foo method'
    end
    
    def self.bar
        puts 'this is the class bar method'
    end
end

Movie.instance_eval do
    def farfaraway
        puts 'this is farfaraway'
    end 
end

#m = Movie.new
#m.type = 'Drama'
#m.price = 19.95
#
#m.info { |t,p| puts "Type:#{t} and Price:#{p}" }
#m.infoo do
#    puts "Infoo: Type:#{self.type} and Price:#{self.price}"
#end
#
#m.foo
#Movie.bar
#Movie.farfaraway

m2 = Movie.new do
    self.type = 'Action'
    self.price = 200    
end

m2.justprint

class Foo
end

class Foo
    class << self
        def foo
            puts 'Foo::foo'
        end
    end
end

Foo.foo
